@model IEnumerable<TaskManager.Domain.BusinessObjects.Project>
@{
    ViewBag.Title = "Projects";
}

<script type="text/javascript">
    $(function () {
        $('#showClosedProjects').click(function () {
            var showFlag = false;

            if ($(this).is(':checked'))
                showFlag = true;

            // Use GET to let this request to be cached
            $.get("/Project/Index", { showClosedProjects: showFlag }, function (data) {
                $('#projectList').html(data);
            });
        });
    });
</script>

@using (Html.BeginForm())
{
    <fieldset class="well">
        <div class="row">
            <div class="span3" style="width: auto">
                @Html.ActionLink("Create New", "Create", null, new { @class = "btn" })
            </div>
            <div class="span3" style="width: auto; margin-top: 5px">
            @if(ViewBag.showClosedProjects)
            {
                <input type="checkbox" id="showClosedProjects" checked="true"  value="Show Closed projects"/>
            }
            else
            {
                <input type="checkbox" id="showClosedProjects" value="Show Closed projects"/>
            }
                <span>Show Closed projects</span>
            </div>
        </div>
    </fieldset>
}
<br />

<div id="projectList">
    @Html.Partial("_ProjectList", Model)
</div>
